#!/bin/sh
#
# $Header: mkinitramfs-ll: /lib/mdev/ide_links           Exp $
# $License: GPL-2                                        Exp $
#

[ -f /proc/ide/$MDEV/media ] || exit

media=`cat /proc/ide/$MDEV/media`
for i in $media $media[0-9]* ; do
	if [ "`readlink $i 2>/dev/null`" = $MDEV ] ; then
		LINK=$i
		break
	fi
done

# link exist, remove if necessary and exit
if [ -n "$LINK" ] ; then
	[ "$ACTION" = remove ] && rm $LINK
	exit
fi

# create a link
num=0
for m in $media[0-9]*; do
	num="$(expr $num + 1)"
done

ln -sf "$MDEV" "$media$num"
[ -e "$media" ] || ln -sf $MDEV "$media"

unset media num

#
# vim:fenc=utf-8:ft=sh:ci:pi:sts=0:sw=4:ts=4:
#
